<?php
define('ROOT', dirname(__FILE__) . '/../');
require_once ROOT . '/common.php';

ujn::runApplication( array(
	'models_path'		=>  ROOT . '/models/',
	'tmp_path'		=> ROOT . '/_tmp/',
	'dhs'				=> $dhs
), ( isset($_GET['cmd']) && function_exists($_GET['cmd']) ) ? $_GET['cmd'] : 'def');

#######################################################################

function get_uid() {
	$puid = isset($_REQUEST['puid']) ? (int)$_REQUEST['puid'] : 0;
	if(empty($puid)) {
		echo '0';
		exit;
	}

	$uid = mdl_account::getInstance()->getAccountUIDBySUID($puid);
	if(empty($uid)) {
		echo json_encode(array('state' => '1',));	
	}else {
		$d = mdl_field::getInstance()->getUserInfoByUID($uid);
		echo json_encode(array(
			'puid'	=> $puid,
			'uid'		=> $uid,
			'mname'	=> $d['name'],
			'icon'	=> $d['icon'],
			'link'	=> '',
		));
	}
}

function get_puid() {
	$uid = isset($_REQUEST['uid']) ? (int)$_REQUEST['uid'] : 0;
	if(empty($uid)) {
		echo '0';
		exit;
	}


	$d = mdl_field::getInstance()->getUserInfoByUID($uid);
	if(empty($uid)) echo json_encode(array(
		'state' => '1',
	));
	else {
		echo json_encode(array(
			'puid'	=> mdl_account::getInstance()->getAccountSUIDByUID($uid),
			'mname'	=> $d['name'],
			'icon'	=> $d['icon'],
			'link'	=> '',
		));
	}
}

function def() {
	echo '404';
}

